﻿package mortal.game.view.copy.sixBoss.renderer
{
    import Message.Client.*;
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.common.display.*;
    import mortal.common.global.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.copy.sixBoss.data.*;
    import mortal.game.view.copy.sixBoss.utils.*;

    public class SixBossRoleInfoListCellRenderer extends GCellRenderer
    {
        private var _rank:GTextFiled;
        private var _serverName:GTextFiled;
        private var _roleName:GTextFiled;
        private var _damageValue:GTextFiled;
        private var _maskBmp:GBitmap;
        private var _damageBar:GImageBitmap;
        private var _rewardItem:BaseItem;
        private var _sPlayerHurtInfo:SMonsterSiegePlayerHurtInfo;

        public function SixBossRoleInfoListCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.SixBossRoleInfoBg, 0, 0, this));
            this._damageBar = UIFactory.gImageBitmap(ImagesConst.SixBossDamageBar, 0, 0, this);
            this._maskBmp = UIFactory.gBitmap(BitmapDataConst.AlphaBMD, 0, 0, this);
            this._maskBmp.width = 128;
            this._maskBmp.height = 23;
            this._damageBar.mask = this._maskBmp;
            this._rank = UIFactory.gTextField("", 13 - 3 - 6, 7 - 6, 18, 20, this);
            this._serverName = UIFactory.gTextField("", 36 - 2, 7 - 6, 70, 20, this);
            this._roleName = UIFactory.gTextField("", 79 - 4, 7 - 6, 100, 20, this);
            this._roleName.configEventListener(TextEvent.LINK, this.onLinkClickHanlder);
            this._roleName.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._roleName.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this._damageValue = UIFactory.gTextField("", 210 - 3 - 6 - 45 - 27, 7 - 6, 100, 20, this, GlobalStyle.textFormatHuang.right());
            this._rewardItem = UICompomentPool.getUICompoment(BaseItem);
            this._rewardItem.setItemStyle(20, "", 2, 2);
            this._rewardItem.x = 229;
            this._rewardItem.isShowPrescritime = false;
            this.addChild(this._rewardItem);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:SixBossOutPutRewardInfo = null;
            super.data = param1;
            if (param1 is SMonsterSiegePlayerHurtInfo)
            {
                this._sPlayerHurtInfo = param1 as SMonsterSiegePlayerHurtInfo;
                this._rank.text = "" + this._sPlayerHurtInfo.rank;
                this._serverName.text = NameUtil.getProxyName(this._sPlayerHurtInfo.entityId, true);
                this._roleName.htmlText = HTMLUtil.addLink(this._sPlayerHurtInfo.name, GlobalStyle.colorHuang);
                this._roleName.x = this._serverName.x + this._serverName.textWidth + 2;
                this._damageValue.text = "" + this._sPlayerHurtInfo.hurt;
                if (SixBossUtil.HighestDamage != 0)
                {
                    this._maskBmp.width = int(256 * (this._sPlayerHurtInfo.hurt / SixBossUtil.HighestDamage));
                }
                _loc_2 = SixBossUtil.getRankRewardByRank(GameController.copy.sixBossCopy.currSelBoss, this._sPlayerHurtInfo.rank);
                if (_loc_2)
                {
                    this._rewardItem.itemCode = _loc_2.itemCode;
                    this._rewardItem.amount = _loc_2.itemAmount;
                }
            }
            else
            {
                this._rank.text = "" + int(param1.data);
                this._serverName.text = "";
                this._roleName.text = "";
                this._roleName.x = this._serverName.x + this._serverName.textWidth + 2;
                this._damageValue.text = "";
                this._maskBmp.width = 0;
                this._rewardItem.itemData = null;
            }
            return;
        }// end function

        private function onLinkClickHanlder(event:TextEvent) : void
        {
            var _loc_2:int = 0;
            if (this._sPlayerHurtInfo)
            {
                _loc_2 = ELookUpType._ELookUpTypePlayer;
                GameProxy.chat.lookupRequest(ELookRoleInfoType._ECommonRoleInfo, this._sPlayerHurtInfo.entityId, _loc_2);
            }
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._rank.dispose();
            this._rank = null;
            this._serverName.dispose();
            this._serverName = null;
            this._roleName.dispose();
            this._roleName = null;
            this._damageValue.dispose();
            this._damageValue = null;
            this._maskBmp.dispose();
            this._maskBmp = null;
            this._damageBar.dispose();
            this._damageBar = null;
            this._rewardItem.dispose();
            this._rewardItem = null;
            this._sPlayerHurtInfo = null;
            return;
        }// end function

    }
}
